<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>医生信息修改页面</title>
    <link href="<%=basePath%>css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/select-ui.min.js"></script>
    <script type="text/javascript">
        $(function(){
            var flag=$("#flag").val();//是否修改的标识
            var deptId = $("#deptid").val();//当前医生所属的科室编号
            if(flag =="" || flag ==null){//首次进入页面
                $.ajax({//查询科室
                    url:"<%=basePath%>deptList?",
                    dataType : "json",
                    //编码设置
                    contentType : "application/json;charset=utf-8",
                    success : function(data) {
                        for(var i=0;i<data.length;i++){
                            if(data[i].departid ==deptId){
                                $("#departid").append("<option value='" + data[i].departid + "' selected>" + data[i].name + "</option>");
                            }else{
                                $("#departid").append("<option value='" + data[i].departid + "' >" + data[i].name + "</option>");
                            }
                        }
                    }
                });
            }else{//保存成功后回显数据
                var deptId = $("#deptid").val();
                $.ajax({//查询科室
                    url:"<%=basePath%>deptlst?departid="+deptId,
                    dataType : "json",
                    //编码设置
                    contentType : "application/json;charset=utf-8",
                    success : function(data) {
                        $("#departid").empty();//先清空
                        $("#departid").append("<option value='" + data[0].departid + "' >" + data[0].name + "</option>");
                    }
                });
            }

        });
    </script>
    <style type="text/css">
        body {
            background:#FFF
        }
    </style>
</head>
<body>
<form method="post" action="<%=basePath%>doctUpdateController" method="post" name="ThisForm">
    <input type="hidden" name="docid" value="${doctor.docid}">
    <input type="hidden" id="deptid" value="${doctor.departid}">
    <input type="hidden"  id="flag" value="${flag }">
    <div id="contentWrap">
        <!--表格控件 -->
        <div id="widget table-widget">
            <div class="pageTitle">医生添加</div>
            <div class="pageInfo">
                <table >
                    <tr>
                        <td width="20%" align="right">医生名</td>
                        <td width="20%"><input type="text" id="name" name="name" value="${doctor.name}" readonly/></td>
                        <td width="10%" align="right">密码</td>
                        <td width="50%"><input type="password" id="password" name="password" value="${doctor.password}"/></td>
                    </tr>
                    <tr>
                        <td align="right">真实姓名</td>
                        <td ><input type="text" id="realname" name="realname" value="${doctor.realname}"/></td>
                        <td align="right">所属科室</td>
                        <td >
                            <select id="departid" name="departid" >

                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">职称</td>
                        <td >
                            <select id="positional" name="positional" >
                                <option value="">请选择</option>
                                <c:if test="${doctor.positional=='01'}"> <option value="01" selected>技师</option> </c:if>
                                <c:if test="${doctor.positional!='01'}"> <option value="01" >技师</option> </c:if>
                                <c:if test="${doctor.positional=='02'}"> <option value="02" selected>主任医师</option> </c:if>
                                <c:if test="${doctor.positional!='02'}"> <option value="02" >主任医师</option> </c:if>
                                <c:if test="${doctor.positional=='03'}"> <option value="03" selected>专家</option> </c:if>
                                <c:if test="${doctor.positional!='03'}"> <option value="03" >专家</option> </c:if>
                            </select>
                        </td>
                        <td align="right">联系电话</td>
                        <td><input type="text" id="tel" name="tel" value="${doctor.tel}"/></td>
                    </tr>
                    <tr>
                        <td align="right">年龄</td>
                        <td ><input type="text" id="age" name="age" value="${doctor.age}"/></td>
                        <td align="right">性别</td>
                        <td > <select id="sex" name="sex" >
                            <c:if test="${doctor.sex=='1'}"> <option value="1" selected>男</option> </c:if>
                            <c:if test="${doctor.sex!='1'}"> <option value="1" >男</option> </c:if>
                            <c:if test="${doctor.sex=='0'}"> <option value="0" selected>女</option> </c:if>
                            <c:if test="${doctor.sex!='0'}"> <option value="0" >女</option> </c:if>
                        </select></td>
                    </tr>
                    <tr>
                        <td align="right">家庭住址</td>
                        <td ><input type="text" id="address" name="address" value="${doctor.address}"/></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td colspan="4" align="center"><input type="submit" value="确定"/> </td>
                    </tr>
                </table>
            </div>
        </div><!-- #widget -->
    </div>
</form>
</body>
</html>
